home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / rayshade-4.0.6.3 / libshade / lex.l < prev    next >
Text File  |  1994-08-09  |  7KB  |  259 lines

  1. /* lex.l                                   */
  2. /* Copyright (C) 1989, 1991, Craig E. Kolb                   */
  3. /* All rights reserved.                               */
  4. /*                                       */
  5. /* This software may be freely copied, modified, and redistributed,       */
  6. /* provided that this copyright notice is preserved on all copies.       */
  7. /*                                       */
  8. /* You may not distribute this software, in whole or in part, as part of   */
  9. /* any commercial product without the express consent of the authors.       */
  10. /*                                        */
  11. /* There is no warranty or other guarantee of fitness of this software       */
  12. /* for any purpose.  It is provided solely "as is".               */
  13. /*                                       */
  14. /* lex.l,v 4.1 1994/08/09 08:04:29 explorer Exp */
  15. %{
  16. #include "config.h"
  17. #include "rayshade.h"
  18. #ifdef I_STRING
  19. #include <string.h>
  20. #else
  21. #include <strings.h>
  22. #endif
  23. #include "liblight/light.h"
  24. #include "libsurf/atmosphere.h"
  25. #include "libsurf/surface.h"
  26. #include "libtext/texture.h"
  27. #include "libobj/geom.h"
  28. #include "libobj/ifs.h"
  29. #include "libobj/mountain.h"
  30. #include "libobj/fractalobject.h"
  31. #include "symtab.h"
  32. #include "y.tab.h"
  33. extern char *strsave();
  34. %}
  35. alpha    [a-zA-Z]
  36. special    [\.\_-]
  37. digit    [0-9]
  38. exp    [Ee][-+]?{digit}+
  39. string    {alpha}({alpha}|{digit}|{special})*
  40. filename "/"?"/"?(("."|".."|{string})"/")*{string}
  41. %p 15000
  42. %e 1500
  43. %n 800
  44. %%
  45. [ \t\n]            ;
  46. ^#            handlehash();
  47. "/*"            skipcomments();
  48. ambient            return tAMBIENT;
  49. aperture        return tAPERTURE;
  50. applysurf        return tAPPLYSURF;
  51. area            return tAREA;
  52. atmosphere        return tATMOSPHERE;
  53. background        return tBACKGROUND;
  54. bezier            return tBEZIER;
  55. blob            return tBLOB;
  56. cblob                   return tCBLOB;
  57. blotch            return tBLOTCH;
  58. body            return tBODY;
  59. box            return tBOX;
  60. bump            return tBUMP;
  61. checker            return tCHECKER;
  62. cloud            return tCLOUD;
  63. coeffs            return tCOEFFS;
  64. cone            return tCONE;
  65. component        return tCOMPONENT;
  66. contrast        return tCONTRAST;
  67. crop            return tCROP;
  68. cursurf            return tCURSURF;
  69. cutoff            return tCUTOFF;
  70. cylinder        return tCYL;
  71. cylindrical        return tCYLINDRICAL;
  72. define            return tDEFINE;
  73. diffuse            return tDIFFUSE;
  74. difference        return tDIFFERENCE;
  75. directional        return tDIRECTIONAL;
  76. disc            return tDISC;
  77. end            return tEND;
  78. extended        return tEXTENDED;
  79. extinct            return tEXTINCT;
  80. eyep            return tEYEP;
  81. eyesep            return tEYESEP;
  82. false            return tFALSE;
  83. filter            return tFILTER;
  84. fbm            return tFBM;
  85. fbmbump            return tFBMBUMP;
  86. flame            return tFLAME;
  87. focaldist        return tFOCALDIST;
  88. fog            return tFOG;
  89. fogdeck            return tFOGDECK;
  90. fov            return tFOV;
  91. fracland        return tFRACLAND;
  92. framelength        return tFRAMELENGTH;
  93. frames            return tFRAMES;
  94. gauss            return tGAUSS;
  95. gloss            return tGLOSS;
  96. gradient        return tGRADIENT;
  97. grid            return tGRID;
  98. heightfield        return tHEIGHTFIELD;
  99. image            return tIMAGE;
  100. index            return tINDEX;
  101. intersect        return tINTERSECT;
  102. jitter            return tJITTER;
  103. light            return tLIGHT;
  104. linear            return tLINEAR;
  105. list            return tLIST;
  106. log            return tLOG;
  107. lookp            return tLOOKP;
  108. map            return tMAP;
  109. marble            return tMARBLE;
  110. maxdepth        return tMAXDEPTH;
  111. mount            return tMOUNT;
  112. mist            return tMIST;
  113. name            return tNAME;
  114. nojitter        return tNOJITTER;
  115. noshadow        return tNOSHADOW;
  116. object            return tOBJECT;
  117. outfile            return tOUTFILE;
  118. plane            return tPLANE;
  119. planar            return tPLANAR;
  120. point            return tPOINT;
  121. poly            return tPOLY;
  122. polygon            return tPOLY;
  123. print            return tPRINT;
  124. projector        return tPROJECTOR;
  125. quiet            return tQUIET;
  126. radial            return tRADIAL;
  127. random            return tRANDOM;
  128. range            return tRANGE;
  129. reflect            return tREFLECT;
  130. reflective        return tREFLECT;
  131. report            return tREPORT;
  132. resolution        return tSCREEN; /* A synonym for screen */
  133. revlog            return tREVLOG;
  134. rotate            return tROTATE;
  135. rotspline               return tROTSPLINE;  /* Rotated cubic spline */
  136. sample            return tSAMPLE;
  137. scale            return tSCALE;
  138. screen            return tSCREEN;
  139. shadowtransp        return tSHADOWTRANSP;
  140. shutter            return tSHUTTER;
  141. sky            return tSKY;
  142. smooth            return tSMOOTH;
  143. sphere            return tSPHERE;
  144. spherical        return tSPHERICAL;
  145. specular        return tSPECULAR;
  146. specpow            return tSPECPOW;
  147. spot            return tSPOT;
  148. starttime        return tSTARTTIME;
  149. stripe            return tSTRIPE;
  150. surface            return tSURFACE;
  151. sweptsph        return tSWEPTSPH;
  152. textsurf        return tTEXTSURF;
  153. texture            return tTEXTURE;
  154. tile            return tTILE;
  155. torus            return tTORUS;
  156. transform        return tTRANSFORM;
  157. translate        return tTRANSLATE;
  158. translu            return tTRANSLU;
  159. translucency        return tTRANSLU;
  160. transp            return tTRANSP;
  161. transparent        return tTRANSP;
  162. triangle        return tTRIANGLE;
  163. triangleuv        return tTRIANGLEUV;
  164. true            return tTRUE;
  165. union            return tUNION;
  166. up            return tUP;
  167. uv            return tUV;
  168. verbose            return tVERBOSE;
  169. window            return tWINDOW;
  170. windy            return tWINDY;
  171. wood            return tWOOD;
  172. xbezier            return tXBEZIER;
  173. ybezier            return tYBEZIER;
  174. zbezier            return tZBEZIER;
  175. xcoeffs            return tXCOEFFS;
  176. ycoeffs            return tYCOEFFS;
  177. zcoeffs            return tZCOEFFS;
  178. normalweighting         return tNORMALWEIGHTING;
  179. minsize                 return tMINSIZE;
  180. lowpass                 return tLOWPASS;
  181. highpass                return tHIGHPASS;
  182. ifs                     return tIFS;
  183. constant                return tCONSTANT;
  184. bounding                return tBOUNDING;
  185. fpoints                 return tFPOINTS;
  186. ftriangles              return tFTRIANGLES;
  187. fentities               return tFENTITIES;
  188. fentity                 return tENTITY;
  189. fractalobject           return tFRACTALOBJECT;
  190. mountain                return tMOUNTAIN;
  191. {digit}+ |
  192. {digit}+"."{digit}*({exp})? |
  193. {digit}*"."{digit}+({exp})? |
  194. {digit}+{exp}        {yylval.d = atof(yytext); return tFLOAT;}
  195. {string}        {yylval.c = strsave(yytext); return tSTRING;}
  196. {filename}        {yylval.c = strsave(yytext); return tFILENAME;}
  197. .            return yytext[0];
  198.  
  199. %%
  200. #ifdef yywrap
  201. #undef yywrap
  202. #endif
  203. yywrap() {return 1;}
  204.  
  205. /*
  206.  * Skip over comments.
  207.  */
  208. skipcomments()
  209. {
  210.     char c;
  211.  
  212.     while (1) {
  213.         while (input() != '*')
  214.                 ;
  215.         if ((c = input()) == '/')
  216.             return;
  217.         unput(c);
  218.     }
  219. }
  220. /*
  221.  * Deal with ccp-produced lines of the form:
  222.  * # n "filename"
  223.  * and
  224.  * # n
  225.  * Where filename is the name of the file being processed, and n is
  226.  * the current line number in that file.
  227.  */
  228. handlehash()
  229. {
  230.     char buf[BUFSIZ];
  231.     int i;
  232.     extern int yylineno;
  233.     extern char yyfilename[];
  234.  
  235.     /*
  236.      * Read the entire line into buf.
  237.      */
  238.     for (i = 0; (buf[i] = input()) != '\n'; i++)
  239.             ;
  240.     unput(buf[i]);        /* To make sure consecutive # lines work. */
  241.     buf[i] = (char)NULL;    /* Replace newline with NULL. */
  242.  
  243.     /*
  244.      * Complain if the line was not of the form #n "filename"
  245.      */
  246.     if ((i = sscanf(buf,"%d \"%[^\"]s\"", &yylineno, yyfilename)) == 0 &&
  247.         (i = sscanf(buf," line %d \"%[^\"]s\"",&yylineno,yyfilename))==0) {
  248.         RLerror(RL_PANIC, "Unknown '#' control (%s).\n",buf);
  249.         exit(1);
  250.     }
  251.     if (i == 1 && (index(buf,'"') != (char *)NULL)) {
  252.         /*
  253.          * Filename was given as ""
  254.          */
  255.         (void)strcpy(yyfilename, "stdin");
  256.     }
  257.         yylineno--;  /* The newline we unput will increment yylineno */
  258. }
  259.